import { createRouter, createWebHistory } from "vue-router"
import { menu } from './menu'

const router = createRouter({
    mode: 'history',
    // history: createWebHashHistory(),//hash 模式
    history: createWebHistory(),//history 模式
    routes: [
        {
            path: "/",
            name: 'container',
            redirect: '/home',
            component: () => import('../views/Container/index.vue'),
            children: menu
        },
        {
            path: '/:pathMatch(.*)',
            name: 'error-404',
            meta: {
                title: '404',
                noToken: true
            },
            component: () => import('@/views/NotFound/index.vue')
        }
    ]
});

//跳转前
router.beforeEach((to, from, next) => {
    //do something
    next()
});

// 跳转后
router.afterEach(() => {
    // do something
    window.scrollTo(0, 0)
});

export default router